package com.szakul.pdf.viewer.dao.beans;



import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;




@Entity
@Table(name = "node")
public class Node implements Serializable{

    /**
	 * 
	 */
	private static final long serialVersionUID = -8486778310737684747L;

	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "nodeId")
    private int id;

    @Column(name = "name")
    private String name;


    @JoinTable(name = "node_leaf", joinColumns = { @JoinColumn(name = "leafId") }, inverseJoinColumns = { @JoinColumn(name = "nodeId") })
    @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)  // pointing Person's address field
    @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.JOIN)
    private Set<Leaf> leaf = new HashSet();

    public Node() {
    }
    
    public Node(final String name) {
    	this.name = name;
    }
    
    /**
     * @return the id
     */
    public int getId() {
        return id;
    }


    /**
     * @param id the id to set
     */
    public void setId(final int id) {
        this.id = id;
    }


    /**
     * @return the name
     */
    public String getName() {
        return name;
    }


    /**
     * @param name the name to set
     */
    public void setName(final String name) {
        this.name = name;
    }



    /**
     * @return the leaf
     */
    public Set<Leaf> getLeaf() {
        return leaf;
    }



    /**
     * @param leaf the leaf to set
     */
    public void setLeaf(final Set<Leaf> leaf) {
        this.leaf = leaf;
    }



}

